package com.simple.configuration.thymeleaf;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.thymeleaf.dialect.AbstractProcessorDialect;
import org.thymeleaf.processor.IProcessor;
import org.thymeleaf.standard.processor.StandardXmlNsTagProcessor;
import org.thymeleaf.templatemode.TemplateMode;

import java.util.HashSet;
import java.util.Set;

/**
 * thymeleaf 自定义方言
 */
public class SysDialect extends AbstractProcessorDialect {

    private static final Logger log = LoggerFactory.getLogger(SysDialect.class);

    //自定义方言名称
    private static final String DIALECT_NAME="Ths Dialect";

    public  SysDialect() {
        super(DIALECT_NAME, "ths", 1000);
    }

    @Override
    public Set<IProcessor> getProcessors(String dialectPrefix) {
        log.info("-->SysDialect getProcessors 执行");
        final Set<IProcessor> processors = new HashSet<>();
        processors.add(new SysProcessor(dialectPrefix));//添加我们定义的标签
        processors.add(new StandardXmlNsTagProcessor(TemplateMode.HTML, dialectPrefix));
        return processors;
    }
}
